from selenium import webdriver
import time
from selenium.webdriver.common.by import By

#3.登录操作
class Ecshop:
    # 初始化实例对象
    def __init__(self):
       self.driver =webdriver.Chrome()


    def search(self):
        #找到首页网址
        self.driver.get('https://ecshop.test2.shopex123.com/')
        #通过name定位免费注册,点击按钮
        self.driver.find_element(By.CLASS_NAME, "reg").click()
        # 通过class定位找到立即登录页面,点击按钮
        self.driver.find_element(By.XPATH ,"//*[@id='sidebar']/div[2]/a").click()


    def register(self):
       self.driver.find_element(By.CLASS_NAME,'inputborder').send_keys('KKSD')
       self.driver.find_element(By.NAME,'password').send_keys('987456.')
       self.driver.find_element(By.CLASS_NAME,'loginbtn').click()

    def quit(self):
        time.sleep(3)
        self.driver.quit()

    # 调用
if __name__ == '__main__':
    su = Ecshop()
    su.search()
    su.register()
    su.quit()
